#include <bits/stdc++.h>
using namespace std;
 
void solve(){
    string s;
    cin >> s;
    s = ' ' + s;
    map<int, int> mp;
    for(int i = 1; i <= s.size() - 3; i++){
        if(s[i] == '1' && s[i + 1] == '1' && s[i + 2] == '0' && s[i + 3] == '0')
            mp[i] = 1;
    }
    int q;
    cin >> q;
    int a, b;
    
    auto func = [&](int a, int b)->void{
        if(s[a] - '0' == b)
            return;
        s[a] = b + '0';
        for(int i = a - 3; i <= a; i++){
            if(mp.count(i)) mp.erase(i);
        }
        for(int i = a - 3; i <= a; i++){
            if(i <= s.size() && i >= 1){
                if(s[i] == '1' && s[i + 1] == '1' && s[i + 2] == '0' && s[i + 3] == '0')
                    mp[i] = 1;
            }
        }
    };
    while(q--){
        cin >> a >> b;
        func(a, b);
        if(mp.size()) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}
 
int main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}